/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/

#include "SimDialog.h"

///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( SimDialog, wxDialog )
	EVT_BUTTON( ID_OK, SimDialog::OnOK )
	EVT_BUTTON( ID_CANCEL, SimDialog::OnCancel )
END_EVENT_TABLE()

SimDialog::SimDialog( wxWindow* parent, int id, wxString title, wxPoint pos, wxSize size, int style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bSizer1;
	bSizer1 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Step size (ms)"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer1->Add( m_staticText1, 0, wxALL, 5 );
	
	SpinCtrl_Step = new wxSpinCtrl( this, wxID_ANY, wxT("20"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000, 20);
	bSizer1->Add( SpinCtrl_Step, 0, wxALL, 5 );
	
	wxString RadioBox_ModeChoices[] = { wxT("Normal"), wxT("Quick") };
	int RadioBox_ModeNChoices = sizeof( RadioBox_ModeChoices ) / sizeof( wxString );
	RadioBox_Mode = new wxRadioBox( this, wxID_ANY, wxT("Simulation mode"), wxDefaultPosition, wxDefaultSize, RadioBox_ModeNChoices, RadioBox_ModeChoices, 2, wxRA_SPECIFY_ROWS );
	bSizer1->Add( RadioBox_Mode, 0, wxALL, 5 );
	
	wxBoxSizer* bSizer2;
	bSizer2 = new wxBoxSizer( wxHORIZONTAL );
	
	Button_OK = new wxButton( this, ID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer2->Add( Button_OK, 0, wxALL, 5 );
	
	Button_Cancel = new wxButton( this, ID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer2->Add( Button_Cancel, 0, wxALL, 5 );
	
	bSizer1->Add( bSizer2, 1, wxEXPAND, 5 );
	
	this->SetSizer( bSizer1 );
	this->Layout();
	bSizer1->Fit( this );

}
void SimDialog::OnOK( wxCommandEvent& event )
{
  int retval;
  //set return value to positive in normal mode and negative in quick mode
  if (RadioBox_Mode->GetSelection()==0)
    retval=SpinCtrl_Step->GetValue();
  else
    retval=SpinCtrl_Step->GetValue()*-1;
  
  EndModal(retval);
}

void SimDialog::OnCancel( wxCommandEvent& event )
{
  EndModal(0);
}

